﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Process.API.Application.Command.Action.ProductionMaterial;
using Process.API.Application.Command.Show;
using Process.API.DTOs;
using Process.Domain;
using Process.ErrorCode;

namespace Process.API.Controllers
{
    /// <summary>
    /// 生产工单 物料清单表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionMaterialController : ControllerBase
    {
        IMediator mediator;

        public ProductionMaterialController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        ///  生产工单 物料清单表批量添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddProductionMaterialCommand([FromBody] AddProductionMaterialCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 生产工单 物料清单表批量删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelProductionMaterialCommand(DelProductionMaterialCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 生产工单 物料清单表显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ProductionMaterialDto>>> ShowProductionMaterialTableCommand([FromQuery]ShowProductionMaterialTableCommand request)
        {
            return await mediator.Send(request);
        }


    }
}
